//
//  AseButton.m
//  HappyTravel
//
//  Created by JiePan’s Mac on 2018/8/3.
//  Copyright © 2018年 Apple. All rights reserved.
//

#import "AseButton.h"

@implementation AseButton

#pragma mark - init
- (id)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super initWithCoder:aDecoder]) {
        [self backOrigin];
    }
    return self;
}

- (id)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        [self backOrigin];
        self.isChanged = NO;
    }
    return self;
}

- (void)setIsChanged:(BOOL)isChanged {
    _isChanged = isChanged;
    if (_isChanged) {
        self.selected = YES;
    }else {
        self.selected = NO;
    }
}

- (void)setTitles:(NSString *)titles {
    [self setTitle:titles forState:UIControlStateNormal];
}

- (void)backOrigin{
    
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.imageView.contentMode = UIViewContentModeScaleAspectFit;
    self.titleLabel.font = [UIFont systemFontOfSize:13];
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect {
    
    CGFloat titleX = 0;
    CGFloat titleY = contentRect.size.height*0.5;
    CGFloat titleW = contentRect.size.width;
    CGFloat titleH = contentRect.size.height - titleY;
    
    return CGRectMake(titleX, titleY, titleW, titleH);
}

- (CGRect)imageRectForContentRect:(CGRect)contentRect {
    
    CGFloat imageW = CGRectGetWidth(contentRect);
    CGFloat imageH = contentRect.size.height*0.35;
    
    return CGRectMake(0, 5, imageW, imageH);
}






@end
